#!/usr/bin/env python
#-*- coding:gbk -*-
u'''
@file tc.py
@brief open folder in totalcommander
@author hulei
@version 1.0
@date 2012-07-30
@copyright 2012 Feitian Technologies Co., Ltd. All rights reserved.
'''

import os, sys

def main():
    tc = os.getenv("PORTABLE_HOME", "D:\\portable") + "\\totalcmd\\totalcmd.exe"

    if len(sys.argv) > 1:
        folder = os.path.abspath(sys.argv[1])
    else:
        folder = os.getcwd()

    if os.path.isdir(folder):
        cmd = '''%s /T /O /P=L /L="%s"''' % (tc, folder)
        ret = os.system(cmd)
        sys.exit(ret)
    else:
        print "folder %s not found!" % folder
        sys.exit(1)

if __name__ == '__main__':
    main()
